#pragma once
#include "Keylistner.h"
#include "Node.h"
#include "Root.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Collections;


namespace RedDot {

	/// <summary>
	/// Summary for DotTree
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class DotTree : public System::Windows::Forms::Form
	{
		
				

	
	private: System::Windows::Forms::TreeView^  treeView1;
	
	
	public:
		System::Collections::Generic::List<System::Windows::Forms::TreeNode^>^ nodes;
		void recRead(Node* node,TreeNode^ tNode) {
			int NoChildren = 0;
			Node* traverser = node->first;
			while(traverser) {
				TreeNode ^tmNode = gcnew TreeNode(gcnew String(traverser->getNodeName().c_str()));
				tmNode->ForeColor = System::Drawing::Color::FromArgb(traverser->getColour());
				tNode->Nodes->Add(tmNode);
				recRead(traverser,tmNode);
				traverser = traverser->next;
			}
			
		}
		DotTree(Root* tree)
		{
			InitializeComponent();
			nodes = gcnew Generic::List<TreeNode^>();
			TreeNode^ root = gcnew TreeNode(gcnew String(tree->getNodeName().c_str()));
			treeView1->Nodes->Add(root);
			recRead(tree,root);

			
			
			
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~DotTree()
		{
			if (components)
			{
				delete components;
			}
		}
	
	protected: 
	private: System::Windows::Forms::Button^  button1;


	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->treeView1 = (gcnew System::Windows::Forms::TreeView());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// treeView1
			// 
			this->treeView1->Location = System::Drawing::Point(21, 16);
			this->treeView1->Name = L"treeView1";
			this->treeView1->Size = System::Drawing::Size(481, 536);
			this->treeView1->TabIndex = 0;
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(508, 16);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(75, 23);
			this->button1->TabIndex = 1;
			this->button1->Text = L"Zamknij";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &DotTree::button1_Click);
			// 
			// DotTree
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(595, 564);
			this->Controls->Add(this->button1);
			this->Controls->Add(this->treeView1);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;
			this->Name = L"DotTree";
			this->Text = L"DotTree";
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 this->Close();
			 }
	};
}
